package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.OrderStatusDao;
import com.itheima.entity.OrderStatus;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.QueryString;
import com.itheima.service.OrderStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;

@Service(interfaceClass = OrderStatusService.class )
@Transactional
public class OrderStatusServiceImpl implements OrderStatusService {
    @Autowired
    private OrderStatusDao orderStatusDao;


    // 分页
    public PageResult findPage(QueryString queryString) {
        Integer pageSize = queryString.getPageSize();
        Integer currentPage = queryString.getCurrentPage();
        PageHelper.startPage(currentPage,pageSize);
        Page<OrderStatus> page = orderStatusDao.selectByCondition(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

   //根据id删除
    public void deleteById(Integer id) {
        orderStatusDao.deleteById(id);
    }
}
